#ifndef WINDOWSMANAGER_H
#define WINDOWSMANAGER_H

#include <defs/global.h>
#include <core/entityobject.h>
#include <QtScript>


namespace Opl { namespace Gui {
        class Scene;
    };};

namespace Optra { namespace Extensions {
        class MainWindow;
        class ZoneInterface;
    };};

class Window;
class QDeclarativeComponent;

O_PRIVATE_DECLARE(WindowsManager);
class WindowsManager : public Opl::Core::EntityObject {
    Q_OBJECT
    Q_PROPERTY(WindowsDisplayMode windowsDisplayMode READ windowsDisplayMode WRITE setWindowsDisplayMode);
public:

	enum WindowsDisplayMode { on_scene, on_desktop };
	Q_ENUMS(WindowsDisplayMode);

	WindowsManager(const QString& configKey, Opl::Core::EntityObject *parent);
	~WindowsManager();

	void initialize();

	WindowsDisplayMode windowsDisplayMode() const;
	void setWindowsDisplayMode(WindowsDisplayMode mode);

	void addScene(QGraphicsScene* scene);

	void addItem(QDeclarativeItem* item);
	void removeItem(QDeclarativeItem* item);

	void addWindow(Optra::Extensions::MainWindow * window);
	void removeWindow(Optra::Extensions::MainWindow* window);
	void removeWindows(Optra::Extensions::ZoneInterface* inf);

	bool registerQMLControl(const QString& className, const QString& script);
private:
	QObject* ObjectFromQMLCommponent(QDeclarativeComponent* commponent);
private slots:
    void reposition();
private:
    O_PRIVATE_DECLARE_MEMBER(WindowsManager)
};

Q_DECLARE_METATYPE(WindowsManager*)



#endif // WINDOWSMANAGER_H

